package com.qf.config;



import com.baomidou.mybatisplus.core.injector.ISqlInjector;
import com.baomidou.mybatisplus.extension.injector.LogicSqlInjector;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import com.baomidou.mybatisplus.extension.plugins.PerformanceInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;

/**
 * @author 刘亚康
 * @Date 2020/3/26
 * @Version 1.0'
 * @Description
 */
@Configuration
@Slf4j
public class MyBatisPlusConfig {
    //逻辑删除的组件
    @Bean
    public ISqlInjector iSqlInjector(){
        return new LogicSqlInjector();
    }

//    /**
//     * 性能分析插件
//     * @return
//     */
//    @Bean
//    @Profile({"dev","test"})
//    public PerformanceInterceptor performanceInterceptor(){
//        PerformanceInterceptor performanceInterceptor = new PerformanceInterceptor();
//        performanceInterceptor.setMaxTime(100);//设置最大时间 ms
//        performanceInterceptor.setFormat(true);
//        return performanceInterceptor;
//    }

    /**
     * 分页插件
     * @return
     */
    @Bean
    public PaginationInterceptor paginationInterceptor(){
        log.info("分页插件启动");
        return new PaginationInterceptor();
    }
}
